showLoading();

function addressList($scope, $http) {
	url = getUrl("22address");
	header = getHeader();
	var allTimes = 0;
	//无默认地址readData(localStorage.account)
	params = 'accountId=' + readData(localStorage.account) + '&defaultAddr=n';
	$http({
		method: 'POST',
		url: url,
		headers: header,
		timeout: 10000,
		//cache: true,
		data: params
	}).success(function(data, status, headers, config) {
		if (data.obj) {
			$scope.addressLists = data.obj.list;
		} else {
			$scope.addressLists = [];
		};
		removeLoading();
	}).error(function(data, status, headers, config) {
		mui.toast('网络链接异常，请稍后重试(e)');
	});
	//默认地址
	par = 'accountId=' + readData(localStorage.account) + '&defaultAddr=y'
	$http({
		method: 'POST',
		url: url,
		headers: header,
		timeout: 10000,
		//cache: true,
		data: par
	}).success(function(data, status, headers, config) {
		if (data.code == "0") {
			$scope.Maddress = data.obj.list[0];
			$scope.status = data.obj.list[0].defaultAddr;
		} else {
			$scope.status = 'n';
		}
	}).error(function(data, status, headers, config) {})

	$scope.addressEdit = function(address) {
		if (address) {
			localStorage.address = writeData(JSON.stringify(address));
		}

		OpenNewWin({
			url: "addAddress.html",
			id: "addAddress.html"
		});
	}
}
window.addEventListener("reload", function() {
	location.reload();
})